package com.itheima.mapper;

import com.itheima.domain.Dept;
import com.itheima.domain.Emp;
import org.apache.ibatis.annotations.One;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface EmpMapper {

    @Select("select * from EMP")
    @Results(value = {
            @Result(id = true,column = "empno", property = "empno"),
            @Result(column = "ename", property = "ename"),
            @Result(column = "job", property = "job"),
            @Result(column = "sal", property = "sal"),
            @Result(column = "hireDate", property = "hireDate"),

            @Result(
                    property = "dept",
                    javaType = Dept.class,
                    column = "deptno",
                    one = @One(select = "com.itheima.mapper.DeptMapper.findById")
            )

    })
    List<Emp> findAll();
}
